package com.nars.datastructures;

public class ListDemo<E> {
	Object[] list;
	int currentIndex;

	public ListDemo(int capacity) {
		list = new Object[capacity];
		currentIndex = 0;
	}

	public Object delete(int x) {
		Object deletedElement = list[x];
		list[x] = null;
		return deletedElement;
	}

	public void insert(E value) {
		if (currentIndex < list.length) {
			list[currentIndex] = value;
			currentIndex++;
		} else {
			System.out.println("List limit exceed");
		}	
	}
	
	public Object search(int x) {		
		return list[x];
	}
	
	public int getLength() {
		return currentIndex;
	}
	
	public void add(Object item) {
		add(currentIndex, item);		
	}
}
